import React from 'react';
import CreateCRModal from './uiless-create-mr-modal';
import { navigate } from 'utils/router';

export default class CRModal extends React.Component {
  render() {
    // const { trigger } = this.props;

    // if (!trigger) {
    //   return null;
    // }
    const plugin = {
      onCreateSuccess: (mr) => {
        navigate(mr.detail_url, {
          state: { forceUpdate: true },
        });
      },
      // 默认库ID
      // defaultProjectId: item.project_id,
      // 默认分支名
      // defaultSourceBranch: item.name,
      // cannotChangeProject: true,
      associateType: 'task', // 可选值： task/codeup; task --- 在任务中新建MR， codeup --- 在code中使用
      // associateId: associatedContext.container.id,
      ...this.props,
    };
    return <CreateCRModal uiless_config={window.UILessConfig} {...plugin} />;
  }
}
